import http from '../utils/request.js'


/**
 * @des 获取Rtmp
 * @param params{ place ,serialNumber}
 **/
export function getRtmp(params) {
    return http({
        url: '/rtmp',
        method: 'get',
        params
    })
}

/**
 * @des 获取RtmpList
 * @param params{place}
 *
 **/
export function getRtmpList(params) {
    return http({
        url: '/rtmp',
        method: 'get',
        params
    })
}

/**
 * @des 打开视频流
 * @param data{}
 * {
  "username": "demoData",
  "password": "demoData",
  "ip": "demoData",
  "channel": "demoData",
  "stream": "demoData",
  "rtsp": "demoData",
  "rtmp": "demoData",
  "url": "demoData",
  "starttime": "demoData", //服务启动时间
  "endtime": "demoData", // 流关闭时间
  "opentime": "demoData", //流打开时间
  "count": 1,
  "token": "demoData"
}
 *
 **/
export function openStream(data) {
    return http({
        url: '/cameras',
        method: 'post',
        data
    })
}

/**
 * 关闭视频流
 * @param tokens
 * @return {AxiosPromise}
 */
export function closeStream(tokens) {
    return http({
        url: `/cameras/${tokens}`,
        method: 'delete'
    })
}

/**
 * 获取所有正在推送的视频流
 * @param tokens
 * @return {AxiosPromise}
 */
export function getStreams() {
    return http({
        url: `/cameras`,
        method: 'get'
    })
}


/**
 * 保活视频流
 * @param tokens
 * @return {AxiosPromise}
 */
export function keepAliveStream(tokens) {
    return http({
        url: `/cameras/${tokens}`,
        method: 'put'
    })
}

/**
 * 获取当前服务信息
 */
export function getServeInfo(){
    return http({
        url: '/status',
        method: 'get'
    })
}
